package controller

import (
	"gin_template/core/app"
	"gin_template/data/e"
	"gin_template/models"
	"gin_template/services"
	"net/http"

	"github.com/gin-gonic/gin"
)

func VerifyToken(c *gin.Context) {
	appG := app.Gin{C: c}
	var tokenModel = models.TokenFormat{}
	httpCode, errCode, validRes := app.BindAndValidWithError(c, &tokenModel)
	if errCode != e.SUCCESS {
		appG.Response(httpCode, errCode, validRes)
		return
	}
	result := services.VerifyToken(&tokenModel)
	varifyResult := ""
	if result {
		varifyResult = tokenModel.Echostr
	}
	appG.Response(http.StatusOK, e.SUCCESS, varifyResult)

}
